<%@ page session="false" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad" prefix="tr"%>
<%@ taglib uri="http://myfaces.apache.org/trinidad/html" prefix="trh"%>
<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%>

<h:panelGroup>
	<fieldset>
	<legend>
	Produkt
	</legend>
	
	
	<table width="50%" border="0">
	<tr>
	<td colspan="2" align="center">
	<h4>Dane produktu <tr:outputText value="#{orderBean.isNetAmount ? '(netto)': '(brutto)'}" /> </h4>
	</td>
	</tr>
	<tr>
	</tr>
		<tr>
			<td align="right">	
				<tr:selectOneChoice label="Wybierz produkt" value="0" id="productListSelect" shortDesc="Lista produktów z pliku excel. Produkty z ceną netto/brutto" 
									autoSubmit="true" valueChangeListener="#{orderController.selectProductChanged}" unselectedLabel="-- wybierz produkt z listy --">
					<t:selectItems value="#{productPriceProvider.products}" var="product" itemValue="#{product}" itemLabel="#{product.name} - #{product.netAmount}/#{product.totalAmount}" />	
				</tr:selectOneChoice>
	
			</td>	
			<td align="right">
				<tr:inputText id="unitpriceList" label="Kwota jednostkowa #{orderBean.isNetAmount ? '(netto)': '(brutto)'}"  
								partialTriggers="productListSelect" required="true"
								value="#{productBean.unitPrice}" contentStyle="width:100px"
								requiredMessageDetail="Cena jednostkowa za zaproszenie jest wymagana">
						<f:convertNumber groupingUsed="false" maxFractionDigits="2" minFractionDigits="2" locale="pl" />
				</tr:inputText> 
					<h:message for="unitpriceList" styleClass="validation_info" />
			</td>
		</tr>
		<tr>
			<td align="right">
				<tr:inputText id="productCode" label="Kod/nazwa" partialTriggers="productListSelect"
								value="#{productBean.code}" shortDesc="Kod towaru"
								maximumLength="70" contentStyle="width:300px" /> 
			</td>
			<td align="right">
			<tr:inputText id="totalCount" label="Ilość" contentStyle="width:50px"
						value="#{productBean.totalCount}" shortDesc="Całkowita ilość"
						required="true" requiredMessageDetail="Ilość musi być większa od 0">
				<f:convertNumber integerOnly="true" />
			</tr:inputText>
			</td>
		</tr>
		<tr>
			<td align="right">
				<tr:inputText columns="60" rows="4" value="#{productBean.note}" 
							shortDesc="Uwagi dodatkowe" label="Uwagi"/>
			</td>
			<td align="right">
					<tr:commandLink action="#{orderController.saveProductItem}"
									shortDesc="Zapisz zmiany">
							<tr:image source="gfx/save_button.png" />
					</tr:commandLink>
			
			</td>
		</tr>
	</table>

	</fieldset>
</h:panelGroup>